import { observable, action, toJS, computed, autorun } from 'mobx';
import motionCONST from 'common/const/observer/motion';
import { Container } from 'stores/models/core/nodeWithList';
import Frame from './frame';

export default class Motion extends Container {
  @observable loop = false;
  @observable autoPlay = false;
  @observable isPlay = false;

  constructor(props, data) {
    super();

    this.init({
      props: {
        parent: props.parent,
        type: 'Motion',
        label: '动效'
      }
    });

    this.addFrame(data);
  }

  @computed get effectElement() {
    return this.list[0].list.map(item => item.realId);
  }

  @action addFrame(data) {
    let frameData = null;

    if (data) {
      frameData = data;
    } else {
      const { list, height } = this.current;
      frameData = {list, height};
    }
    // console.log(frameData);

    this.insert(new Frame({parent: this}, frameData));
  }
}
